package com.mall.initialize;


import com.alibaba.fastjson.JSON;
import com.mall.common.domain.MallProductType;
import com.mall.common.domain.response.MallProductTypeRes;
import com.mall.product.mapper.ProductTypeMapper;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author wangy
 * @version 1.0
 * @description: TODO
 */
@Component
@Order
public class TypeInitialize {
    @Resource
    private ProductTypeMapper productTypeMapper;
    private static final int PARENT_ID = 0;
    @Resource
    private RedisTemplate<String,String> redisTemplate;
    @PostConstruct
    public void productTypeAll() {
        List<MallProductType> mallProductTypes = productTypeMapper.selectProductTypeList(PARENT_ID);
        redisTemplate.opsForList().rightPushAll("type", JSON.toJSONString(mallProductTypes));
    }
}
